home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-03 | 7.2 KB | 234 lines | [TEXT/MPS ] |
- ;
- ; File: Threads.a
- ;
- ; Contains: Assembly language interface to the Thread Manager
- ;
- ; Copyright: © 1990-1994 by Apple Computer, Inc., all rights reserved.
- ;
-
- ;————————————————————————————————————————————————————————————————————————————————————————————————————
- IF &TYPE('__IncludingThreads__') = 'UNDEFINED' THEN
- __IncludingThreads__ SET 1
-
- ;————————————————————————————————————————————————————————————————————————————————————————————————————
- IF &TYPE('__INCLUDINGTRAPS__') = 'UNDEFINED' THEN
- INCLUDE 'Traps.a'
- ENDIF
- ;————————————————————————————————————————————————————————————————————————————————————————————————————
- IF &TYPE('_ThreadDispatch') = 'UNDEFINED' THEN
- _ThreadDispatch OPWORD $ABF2
- ENDIF
- ;————————————————————————————————————————————————————————————————————————————————————————————————————
- gestaltThreadMgrAttr EQU 'thds' ;Thread Manager attributes
- gestaltThreadMgrPresent EQU 0 ; bit true if Thread Mgr is present
- gestaltSpecificMatchSupport EQU 1 ; bit true if Thread Mgr supports exact match creation option
- gestaltThreadsLibraryPresent EQU 2 ; bit true if ThreadsLibrary (Native version) has been loaded
-
- ;————————————————————————————————————————————————————————————————————————————————————————————————————
- ; Thread states
- kReadyThreadState EQU 0
- kStoppedThreadState EQU 1
- kRunningThreadState EQU 2
-
- ;————————————————————————————————————————————————————————————————————————————————————————————————————
- ; Thread characteristics (bit numbers in ThreadStyle)
- kCooperativeThread EQU 0
- kPreemptiveThread EQU 1
-
- ;————————————————————————————————————————————————————————————————————————————————————————————————————
- ; Thread identifiers
- MACRO
- ThreadID
- DS.L 1
- ENDM
- kNoThreadID EQU 0
- kCurrentThreadID EQU 1
- kApplicationThreadID EQU 2
-
- ;————————————————————————————————————————————————————————————————————————————————————————————————————
- ; Options when creating a thread (bit numbers in ThreadOptions)
- kNewSuspend EQU 0
- kUsePremadeThread EQU 1
- kCreateIfNeeded EQU 2
- kFPUNotNeeded EQU 3
- kExactMatchThread EQU 4
-
- ;————————————————————————————————————————————————————————————————————————————————————————————————————
- ; Information supplied to the custom scheduler
- SchedulerInfoRec RECORD 0
- InfoRecSize DS.L 1
- CurrentThreadID ThreadID
- SuggestedThreadID ThreadID
- InterruptedSyncThreadID ThreadID
- Size EQU *
- ENDR
-
- ;————————————————————————————————————————————————————————————————————————————————————————————————————
- ; Define the selectors for the Thread Manager
- selectCreateThreadPool EQU 1
- selectGetFreeThreadCount EQU 2
- selectNewThread EQU 3
- selectDisposeThread EQU 4
- selectYieldToThread EQU 5
- selectGetCurrentThread EQU 6
- selectGetThreadState EQU 7
- selectSetThreadState EQU 8
- selectSetThreadScheduler EQU 9
- selectSetThreadSwitcher EQU 10
- selectThreadBeginCritical EQU 11
- selectThreadEndCritical EQU 12
- selectSetDebuggerNotificationProcs EQU 13
- selectGetThreadCurrentTaskRef EQU 14
- selectGetThreadStateGivenTaskRef EQU 15
- selectSetThreadReadyGivenTaskRef EQU 16
- selectSetThreadTerminator EQU 17
- selectSetThreadStateEndCritical EQU 18
- selectGetDefaultThreadStackSize EQU 19
- selectThreadCurrentStackSpace EQU 20
- selectGetSpecificFreeThreadCount EQU 21
-
- ;————————————————————————————————————————————————————————————————————————————————————————————————————
- ; Define the parameter size passed for each call
- paramWordsCreateThreads EQU 5
- paramWordsGetFreeThreadCount EQU 4
- paramWordsNewThread EQU 14
- paramWordsDisposeThread EQU 5
- paramWordsYieldToThread EQU 2
- paramWordsGetCurrentThread EQU 2
- paramWordsGetThreadState EQU 4
- paramWordsSetThreadState EQU 5
- paramWordsSetThreadScheduler EQU 2
- paramWordsSetThreadSwitcher EQU 7
- paramWordsThreadBeginCritical EQU 0
- paramWordsThreadEndCritical EQU 0
- paramWordsSetDebuggerNotificationProcs EQU 6
- paramWordsGetThreadCurrentTaskRef EQU 2
- paramWordsGetThreadStateGivenTaskRef EQU 6
- paramWordsSetThreadReadyGivenTaskRef EQU 4
- paramWordsSetThreadTerminator EQU 6
- paramWordsSetThreadStateEndCritical EQU 5
- paramWordsGetDefaultThreadStackSize EQU 4
- paramWordsThreadCurrentStackSpace EQU 4
- paramWordsGetSpecificFreeThreadCount EQU 6
-
- ;————————————————————————————————————————————————————————————————————————————————————————————————————
- ; Errors *** put actual number in SysErr.a
- threadTooManyReqsErr EQU -617
- threadNotFoundErr EQU -618 ; no thread with specified identifier
- threadProtocolErr EQU -619
-
- ;————————————————————————————————————————————————————————————————————————————————————————————————————
- ; Thread Manager routines
- MACRO
- _CreateThreads
- DoDispatch _ThreadDispatch,selectCreateThreads,paramWordsCreateThreads
- ENDM
-
- MACRO
- _GetFreeThreadCount
- DoDispatch _ThreadDispatch,selectGetFreeThreadCount,paramWordsGetFreeThreadCount
- ENDM
-
- MACRO
- _GetSpecificFreeThreadCount
- DoDispatch _ThreadDispatch,selectGetSpecificFreeThreadCount,paramWordsGetSpecificFreeThreadCount
- ENDM
-
- MACRO
- _GetDefaultThreadStackSize
- DoDispatch _ThreadDispatch,selectGetDefaultThreadStackSize,paramWordsGetDefaultThreadStackSize
- ENDM
-
- MACRO
- _ThreadCurrentStackSpace
- DoDispatch _ThreadDispatch,selectThreadCurrentStackSpace,paramWordsThreadCurrentStackSpace
- ENDM
-
- MACRO
- _NewThread
- DoDispatch _ThreadDispatch,selectNewThread,paramWordsNewThread
- ENDM
-
- MACRO
- _DisposeThread
- DoDispatch _ThreadDispatch,selectDisposeThread,paramWordsDisposeThread
- ENDM
-
- MACRO
- _YieldToThread
- DoDispatch _ThreadDispatch,selectYieldToThread,paramWordsYieldToThread
- ENDM
-
- MACRO
- _YieldToAnyThread
- clr.l -(sp)
- _YieldToThread
- ENDM
-
- MACRO
- _GetCurrentThread
- DoDispatch _ThreadDispatch,selectGetCurrentThread,paramWordsGetCurrentThread
- ENDM
-
- MACRO
- _GetThreadState
- DoDispatch _ThreadDispatch,selectGetThreadState,paramWordsGetThreadState
- ENDM
-
- MACRO
- _SetThreadState
- DoDispatch _ThreadDispatch,selectSetThreadState,paramWordsSetThreadState
- ENDM
-
- MACRO
- _SetThreadStateEndCritical
- DoDispatch _ThreadDispatch,selectSetThreadStateEndCritical,paramWordsSetThreadStateEndCritical
- ENDM
-
- MACRO
- _SetThreadScheduler
- DoDispatch _ThreadDispatch,selectSetThreadScheduler,paramWordsSetThreadScheduler
- ENDM
-
- MACRO
- _SetThreadSwitcher
- DoDispatch _ThreadDispatch,selectSetThreadSwitcher,paramWordsSetThreadSwitcher
- ENDM
-
- MACRO
- _SetThreadTerminator
- DoDispatch _ThreadDispatch,selectSetThreadTerminator,paramWordsSetThreadTerminator
- ENDM
-
- MACRO
- _ThreadBeginCritical
- DoDispatch _ThreadDispatch,selectThreadBeginCritical,paramWordsThreadBeginCritical
- ENDM
-
- MACRO
- _ThreadEndCritical
- DoDispatch _ThreadDispatch,selectThreadEndCritical,paramWordsThreadEndCritical
- ENDM
-
- MACRO
- _SetDebuggerNotificationProcs
- DoDispatch _ThreadDispatch,selectSetDebuggerNotificationProcs,paramWordsSetDebuggerNotificationProcs
- ENDM
-
- MACRO
- _GetThreadCurrentTaskRef
- DoDispatch _ThreadDispatch,selectGetThreadCurrentTaskRef,paramWordsGetThreadCurrentTaskRef
- ENDM
-
- MACRO
- _GetThreadStateGivenTaskRef
- DoDispatch _ThreadDispatch,selectGetThreadStateGivenTaskRef,paramWordsGetThreadStateGivenTaskRef
- ENDM
-
- MACRO
- _SetThreadReadyGivenTaskRef
- DoDispatch _ThreadDispatch,selectSetThreadReadyGivenTaskRef,paramWordsSetThreadReadyGivenTaskRef
- ENDM
-
- ENDIF ; Already included
-